﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Interface
{
    /// <summary>
    /// Interaction logic for Login.xaml
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            InitializeComponent();
        }

        private void regiterBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string cargo=Proceso.GestorUsuario.Loguearse(txbxUser.Text,Utilidades.EncriptorAES.Encriptar(txbxPass.Password));
                lblerror.Content = "";
                if(cargo=="Vendedor")
                {
                    VariablePrivilegio.nivel = "VENDEDOR";
                    VendedorPrincipal vend = new VendedorPrincipal();
                    vend.Show();
                }
                if (cargo == "Administrador")
                {
                    VariablePrivilegio.nivel = "ADMINISTRADOR";
                    MainWindow m = new MainWindow();
                    m.Show();
                }
                if (cargo == "Encargado de Almacen")
                {
                    VariablePrivilegio.nivel = "ALMACENERO";
                    AlmacenPrincipal almacen = new AlmacenPrincipal();
                    almacen.Show();
                }  
                this.Close();
            }
            catch (Exception ex)
            {

                lblerror.Content = ex.Message;
            }
        }
    }
}
